<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>自定义-日期</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
    <meta name="generator" content="www.leipi.org" />
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.css">
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="bootstrap/bootstrap-ie6.css">
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="css/ie.css">
    <![endif]-->
    <link rel="stylesheet" href="../css/style.css">
    <script type="text/javascript" src="../js/internal.js"></script>
    <script type="text/javascript">
/* Thank you by  
http://www.alt-tag.com/blog/2006/02/ie-dom-bugs/ */
function createElement(type, name)
{     
    var element = null;     
    try {        
        element = document.createElement('<'+type+' name="'+name+'">');     
    } catch (e) {}   
    if(element==null) {     
        element = document.createElement(type);     
        element.name = name;     
    } 
    return element;     
}
    </script>
</head>
<body>
<div class="content">
    <table class="table table-bordered table-striped table-hover">
     <tr>
        <th><span>开始时间名称： </span><span class="label label-important">*</span></th>
        <th><span>结束时间名称： </span><span class="label label-important">*</span></th>
    </tr>
    <tr>
        <td><input type="text" id="orgnamestart" placeholder="必填项"></td>
        <td><input type="text" id="orgnameend" placeholder="必填项"></td>
    </tr>
     <tr>
        <th><span>开始时间默认值： </span><span class="label label-important">*</span></th>
        <th><span>结束时间默认值： </span><span class="label label-important">*</span></th>
    </tr>
    <tr>
        <td><input type="text" id="orgvaluestart" value="2016-06-01" placeholder="开始时间"></td>
        <td><input type="text" id="orgvalueend" value="2016-06-01" placeholder="结束时间"></td>
    </tr>
     <tr>
         <th><span>长*宽*字体大小</span></th>
         <th><span>对齐方式</span></th>
    </tr>
    <tr>
         <td>
            <input id="orgwidth" type="text" value="150" class="input-small span1" placeholder="auto"/>X
            <input id="orgheight" type="text" value="" class="input-small span1" placeholder="auto"/>&
            <input id="orgfontsize" type="text"  value="" class="input-small span1" placeholder="auto"/>px
        </td>
        <td>
            <select id="orgalign">
                <option value="center">居中对齐</option>
                <option value="left" >左对齐</option>
                <option value="right">右对齐</option>
            </select>
        </td>
    </tr>
     <tr>
         <th><span>可见性 </span></th>
    </tr>
    <tr>
         <td>
            <label class="checkbox inline"><input id="orghide" type="checkbox"/> 隐藏 </label>
        </td>
    </tr>
    </table>
</div>

<script type="text/javascript">
var oNode = null,oNode_two = null,thePlugins = 'text';

window.onload = function() {
	 if( UE.plugins[thePlugins].editdom ){
	        oNode = UE.plugins[thePlugins].editdom;
	        oNode_two = UE.plugins[thePlugins].editdom;
			var gHidden=oNode.getAttribute('orghide'),
			gFontSize=oNode.getAttribute('orgfontsize'),
			gAlign=oNode.getAttribute('orgalign'),
			gWidth=oNode.getAttribute('orgwidth'),
			gHeight=oNode.getAttribute('orgheight'),
			gOrgnamestart=oNode.getAttribute('orgnamestart'),
			gOrgvaluestart=oNode.getAttribute('orgvaluestart');
			
			var gHidden=oNode_two.getAttribute('orghide'),
			gFontSize=oNode_two.getAttribute('orgfontsize'),
			gAlign=oNode_two.getAttribute('orgalign'),
			gWidth=oNode_two.getAttribute('orgwidth'),
			gHeight=oNode_two.getAttribute('orgheight'),
			gOrgnameend=oNode.getAttribute('orgnameend'),
			gOrgvalueend=oNode.getAttribute('orgvalueend');
			
			//gValue = oNode.getAttribute('value').replace(/&quot;/g,"\""),gTitle=oNode.getAttribute('title').replace(/&quot;/g,"\""),
			//gValue = gValue==null ? '' : gValue;
	        //gTitle = gTitle==null ? '' : gTitle;
	            
	        gOrgnamestart = gOrgnamestart==null ? '' : gOrgnamestart;
	        gOrgnameend = gOrgnameend==null ? '' : gOrgnameend;
	        gOrgvaluestart = gOrgvaluestart==null ? '' : gOrgvaluestart;
	        gOrgvalueend = gOrgvalueend==null ? '' : gOrgvalueend;
      
			//$G('orgvalue').value = gValue;
	        //$G('orgname').value = gTitle;       
	        $G('orgnamestart').value = gOrgnamestart;//开始时间名称
	        $G('orgnameend').value = gOrgnameend;//结束时间名称
	        $G('orgvaluestart').value = gOrgvaluestart;//设置默认开始时间
	        $G('orgvalueend').value = gOrgvalueend;//设置默认结束时间  	 
	        if (gHidden == '1')
	        {
	            $G('orghide').checked = true;
	        }
	        $G('orgfontsize').value = gFontSize;
	        $G('orgwidth').value = gWidth;
	        $G('orgheight').value = gHeight;
	        $G('orgalign').value = gAlign; 
	      }
}
//取消
dialog.oncancel = function () {
    if( UE.plugins[thePlugins].editdom ) {
        delete UE.plugins[thePlugins].editdom;
    }
};

//确定按钮
dialog.onok = function (){
	 if($G('orgnamestart').value==''){
	    	console.log('请输入开始时间名称');
	        alert('请输入开始时间名称');
	        return false;
	    }
	 if($G('orgnameend').value==''){
	    	console.log('请输入结束时间名称');
	        alert('请输入结束时间名称');
	        return false;
	    }
	   /*  判断默认值 如何需要 作为必要条件加上
			 if($G('orgvaluestart').value==''){
				console.log('请输入默认值');
			    alert('请输入默认值');
			    return false;
			}
	   */
	   //var gValue=$G('orgvalue').value.replace(/\"/g,"&quot;"),gTitle=$G('orgname').value.replace(/\"/g,"&quot;"),gFontSize=$G('orgfontsize').value,gAlign=$G('orgalign').value,gWidth=$G('orgwidth').value,gHeight=$G('orgheight').value,gType=$G('orgtype').value,gBackground=$G('orgbackground').value;
var gOrgnamestart = $G('orgnamestart').value,gOrgnameend = $G('orgnameend').value,gOrgvaluestart = $G('orgvaluestart').value,gOrgvalueend = $G('orgvalueend').value,gFontSize=$G('orgfontsize').value,gAlign=$G('orgalign').value,gWidth=$G('orgwidth').value,gHeight=$G('orgheight').value;
	    
	   if( !oNode ) {
	        try {
	            oNode = createElement('input','leipiNewField');
	            oNode.setAttribute('type','input');
	            oNode.setAttribute('class','g_date');
	            oNode.setAttribute('title',gOrgnamestart);//开始时间名称
	            oNode.setAttribute('value',gOrgvaluestart);//开始时间默认值
	            oNode.setAttribute('name','leipiNewField');
	            oNode.setAttribute('leipiPlugins',thePlugins);
	            
	            oNode_two = createElement('input','leipiNewField');
	            oNode_two.setAttribute('type','input');
	            oNode_two.setAttribute('class','g_date');
	            oNode_two.setAttribute('title',gOrgnameend);//开始时间名称
	            oNode_two.setAttribute('value',gOrgvalueend);//开始时间默认值
	            oNode_two.setAttribute('name','leipiNewField');
	            oNode_two.setAttribute('leipiPlugins',thePlugins);
	            if ( $G('orghide').checked ) {
	                oNode.setAttribute('orghide',1);//开始时间 
	                oNode_two.setAttribute('orghide',1);//结束时间隐藏状态 
	            } else {
	                oNode.setAttribute('orghide',0);
	                oNode_two.setAttribute('orghide',0);
	            }
	            if( gFontSize != '' ) {
	                oNode.style.fontSize = gFontSize + 'px';
	                //style += 'font-size:' + gFontSize + 'px;';
	                oNode.setAttribute('orgfontsize',gFontSize );
	                oNode_two.setAttribute('orgfontsize',gFontSize );
	            }
	            if( gAlign != '' ) {
	                //style += 'text-align:' + gAlign + ';';
	                oNode.style.textAlign = gAlign;
	                oNode_two.style.textAlign = gAlign;
	                oNode.setAttribute('orgalign',gAlign );
	                oNode_two.setAttribute('orgalign',gAlign );
	            }
	            if( gWidth != '' ) {
	                oNode.style.width = gWidth+ 'px';
	                oNode_two.style.width = gWidth+ 'px';
	                //style += 'width:' + gWidth + 'px;';
	                oNode.setAttribute('orgwidth',gWidth );
	                oNode_two.setAttribute('orgwidth',gWidth );
	            }
	            if( gHeight != '' ) {
	                oNode.style.height = gHeight+ 'px';
	                oNode_two.style.height = gHeight+ 'px';
	                //style += 'height:' + gHeight + 'px;';
	                oNode.setAttribute('orgheight',gHeight );
	                oNode_two.setAttribute('orgheight',gHeight );
	            }
	                    
	            //oNode.setAttribute('style',style );
	            //oNode.style.cssText=style;//ie7
	            console.log(oNode.outerHTML);
	            console.log(oNode_two.outerHTML);
	            
	            editor.execCommand('insertHtml',oNode.outerHTML);
	            editor.execCommand('insertHtml',"&nbsp;-&nbsp;"+oNode_two.outerHTML);
	            
	        } catch (e) {
	            try {
	                editor.execCommand('error');
	            } catch ( e ) {
	                alert('控件异常!!');
	            }
	            return false;
	        }
	    }  else {
	        console.log("这里====没走======");
	        oNode.setAttribute('title', gOrgnamestart);
	        oNode.setAttribute('value', $G('orgvaluestart').value);
	        if( $G('orghide').checked ) {
	            oNode.setAttribute('orghide', 1);
	        } else {
	            oNode.setAttribute('orghide', 0);
	        }
	        if( gFontSize != '' ) {
	            oNode.style.fontSize = gFontSize+ 'px';
	            oNode.setAttribute('orgfontsize',gFontSize );
	        }else{
	            oNode.style.fontSize = '';
	            oNode.setAttribute('orgfontsize', '');
	        }
	        if( gAlign != '' ) {
	            oNode.style.textAlign = gAlign;
	            oNode.setAttribute('orgalign',gAlign );
	        }else{
	            oNode.setAttribute('orgalign', '');
	        }
	        if( gWidth != '' ) {
	            oNode.style.width = gWidth+ 'px';
	            oNode.setAttribute('orgwidth',gWidth );
	        }else{
	            oNode.style.width = '';
	            oNode.setAttribute('orgwidth', '');
	        }
	        if( gHeight != '' ) {
	            oNode.style.height = gHeight+ 'px';
	            oNode.setAttribute('orgheight',gHeight );
	        }else{
	            oNode.style.height = '';
	            oNode.setAttribute('orgheight', '');
	        }
	        /*
	        if( gType != '' ) {
	            oNode.setAttribute('orgtype',gType );
	        }else{
	            oNode.setAttribute('orgtype', '');
	        }
	        */
	        delete UE.plugins[thePlugins].editdom;
	    }
	    		   
}


</script>
</body>
</html>